package xyz.riceball.springcloudstreamstudy;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;

import java.time.LocalDateTime;
import java.util.function.Consumer;

// @checkstyle:off
/**
 * Consumer.
 *
 * @author xiaovcloud
 * @since 2024/6/12 10:50
 */
@Configuration
public class ConsumerConfig {

	@Bean("myOutput")
	public Consumer<Message<String>> myOutput() {
		return (message) -> {
			MessageHeaders headers = message.getHeaders();
			String payload = message.getPayload();
			System.out.println("消息已接受"+ LocalDateTime.now());
			System.out.println("myOutput head is : " + headers);
			System.out.println("myOutput payload is : " + payload);
		};
	}
}
// @checkstyle:on
